var perm = function(s) {
    let result = []
    if(s.length <= 1){
        return [s]
    }else{
        for(let i = 0;i < s.length;i++){
            let c = s[i]
            let newStr = s.slice(0,i) + s.slice(i+1,s.length)
            let l = perm(newStr)
            for(let j = 0;j < newStr.length ; j++){
                let res = c + newStr[j]
                result.push(res)
            }
        }
    }
    return result
  };  
console.log(perm('acb'));